home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Hot Mix 17
/
Hot Mix 17.iso
/
HM17_SGI
/
research
/
lib
/
caldat.pro
< prev
next >
Wrap
Text File
|
1997-07-08
|
2KB
|
91 lines
; $Id: caldat.pro,v 1.4 1997/01/15 03:11:50 ali Exp $
;
; Copyright (c) 1992-1997, Research Systems, Inc. All rights reserved.
; Unauthorized reproduction prohibited.
;
pro CALDAT, Julian, Month, Day, Year, Hour, Minute, Second
;+
; NAME:
; CALDAT
;
; PURPOSE:
; Return the calendar date and time given julian date.
; This is the inverse of the function JULDAY.
; CATEGORY:
; Misc.
;
; CALLING SEQUENCE:
; CALDAT, Julian, Month, Day, Year, Hour, Minute, Second
; See also: julday, the inverse of this function.
;
; INPUTS:
; JULIAN contains the Julian Day Number (which begins at noon) of the
; specified calendar date. It should be a long integer.
; OUTPUTS:
; (Trailing parameters may be omitted if not required.)
; MONTH: Number of the desired month (1 = January, ..., 12 = December).
;
; DAY: Number of day of the month.
;
; YEAR: Number of the desired year.
;
; HOUR: Hour of the day
; Minute: Minute of the day
; Second: Second (and fractions) of the day.
;
; COMMON BLOCKS:
; None.
;
; SIDE EFFECTS:
; None.
;
; RESTRICTIONS:
; Accuracy using IEEE double precision numbers is approximately
; 1/10000th of a second.
;
; MODIFICATION HISTORY:
; Translated from "Numerical Recipies in C", by William H. Press,
; Brian P. Flannery, Saul A. Teukolsky, and William T. Vetterling.
; Cambridge University Press, 1988 (second printing).
;
; DMS, July, 1992.
; Added Hours, Minutes, Secs, April, 1996.
;-
;
ON_ERROR, 2 ; Return to caller if errors
IGREG = 2299161L ;Beginning of Gregorian calendar
jul = long(julian) ;Better be long
f = julian - jul
if f ne 0.0 then begin ;Get hours, minutes, seconds.
hour = floor(f * 24.)
f = f - hour / 24.d0
minute = floor(f*1440)
second = (f - minute/1440.d0) * 86400.0d0
endif else begin
hour = 0L
minute = 0L
second = 0L
endelse
if jul ge igreg then begin
jalpha = long(((jul - 1867216) - 0.25d0) / 36524.25)
ja = jul + 1 + jalpha - long(0.25d0 * jalpha)
endif else ja = jul
jb = ja + 1524
jc = long(6680.0 + ((jb-2439870)-122.1)/365.25)
jd = long(365 * jc + (0.25 * jc))
je = long((jb - jd) / 30.6001)
day = jb - jd - long(30.6001 * je)
month = je -1
if (month gt 12) then month = month - 12
year = jc - 4715
if month gt 2 then year = year - 1
if year le 0 then year = year - 1
end